﻿<phone:PhoneApplicationPage 
    x:Class="VkontakteMangoClient.MessagesPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:VkontakteViewModel="clr-namespace:VkontakteViewModel;assembly=VkontakteViewModel"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    toolkit:TiltEffect.IsTiltEnabled="True">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    
    <phone:PhoneApplicationPage.Resources>
        <VkontakteViewModel:MessagesPageViewModel x:Name="messagesPageSource" />
        <DataTemplate x:Key="MessageViewModelTemplate">
        	<StackPanel Width="460" Orientation="Horizontal" Margin="0 12 0 12">
        		<StackPanel>
        			<Image Source="{Binding User.PhotoMedium}" Margin="12 12 0 0" Height="100" Width="100" Stretch="UniformToFill" VerticalAlignment="Top" />
        			<TextBlock Text="{Binding User.LastName}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
        			<TextBlock Text="{Binding User.FirstName}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
        			<TextBlock Text="{Binding User.Nickname}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
				</StackPanel>
                <StackPanel Margin="0" Width="336" d:LayoutOverrides="Margin">
        			<TextBlock Text="{Binding Title, Mode=OneWay}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>	    		
					<TextBlock Text="{Binding Date, Mode=OneWay}" Style="{StaticResource PhoneTextSubtleStyle}"/>
					<TextBlock Text="{Binding Body, Mode=OneWay}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0,0,0"/>
				</StackPanel>
        	</StackPanel>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    <phone:PhoneApplicationPage.DataContext>
        <Binding Source="{StaticResource messagesPageSource}"></Binding>
    </phone:PhoneApplicationPage.DataContext>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="PageTitle" Text="{Binding Resource.Messages}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        	<ListBox ItemTemplate="{StaticResource MessageViewModelTemplate}" 
                     ItemsSource="{Binding Messages}"
                     SelectionChanged="ListBoxMessages_OnSelectionChanged"
                     />
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/home.png" Text="Home" Click="ApplicationBarIconButtonHome_OnClick"/>
            <shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.favs.addto.rest.png" Text="Pin to start" Click="ApplicationBarMenuItemPinToStart_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.refresh.rest.png" Text="Refresh" Click="ApplicationBarIconButton_OnClick"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Pint to start" Click="ApplicationBarMenuItemPinToStart_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
